package practice01;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice01
 * @ClassName: LookHtml
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/30 18:24
 * @Copyright 大牛版板所有
 */
public class LookHtml {

    public static void getNetHtml(String url,String charsetName){
        BufferedReader reader = null;
        try {
            URL url1 = new URL(url);
            URLConnection urlConnection = url1.openConnection();
            reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(),charsetName));
            String line;
            while ((line=reader.readLine()) != null){
                System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (reader != null){
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        String url = "https://www.cnblogs.com/itboxue/p/10738810.html";
        getNetHtml(url,"UTF-8");
    }
}
